// import DarkIcon from '@mui/icons-material/DarkMode.js';
// import LightIcon from '@mui/icons-material/LightMode.js';
var React=require('react')
let fs=require("fs")
// import { renderToString } from 'react-dom/server';
// let l=React.createElement("LightIcon")
// let d=React.createElement("DarkIcon")
// let r=React.createElement("div",{},l,d)
// console.log(renderToString(r));
var ReactDOMServer = require('react-dom/server');
function changeOne(one){
    return new Promise(
      function (resolve, reject) {
        var F1=require("@mui/icons-material/"+one).default;
        var str=ReactDOMServer.renderToString(React.createElement(F1, null))
        const file = fs.createWriteStream("icons/"+one+".svg");
        file.write(str);
        file.end();
        file.on('close', () => {
          console.log(one);
          resolve('成功') // 数据处理完成
        });
      }
    )
}
async function main(){
    // "KeyboardArrowUp"
    let files2=["KeyboardArrowUp.js","KeyboardArrowDown.js"]
    for(var i=0;i<files2.length;i++){
       await changeOne(files2[i]);
    }
}
async function treatfile(err,files){
      if(err){
        throw err;
      }
      for(var i=0;i<files.length;i++){
        let file=files[i]
        if(file.endsWith(".js")){
          await changeOne(file);
        }
      }
}
async function main2(){
    fs.readdir("node_modules/@mui/icons-material",treatfile)
}
main()